package cn.doitedu.kafka;

import java.util.ArrayList;

public class A03数组 {
    public static void main(String[] args) {

        // 数组也是一种数据类型(复合)
        int[] a = {1,2,3};
        int[] b = new int[]{2,4,6};


        // 搞一个数组装3个person对象
        Person p1 = new Person("zs",18);
        Person p2 = new Person("ks",28);

        Person[] personArray = {p1,p2};

        // 红象   宝洁  陈阳
        String[] names = {"红象","宝洁","陈阳"};


        ArrayList<String> listA = new ArrayList<>();
        ArrayList<String> listB = new ArrayList<>();
        ArrayList<String> listC = new ArrayList<>();

        ArrayList<String>[] listArray = new ArrayList[]{listA,listB,listC};

        // 定义一个数组，装入3个Student对象
        Student s1 = new Student(18, "a");
        Student s2 = new Student(20, "b");
        Student[]  ss = {s1,s2};


        Student[] sx = { new Student(18, "zs"), new Student(38, "李四")};


        // 数组的操作

        // 取值
        Student sx0 = sx[0];
        System.out.println(sx[0]);

        //
        System.out.println(sx[2]);


        // 改值
        Student wangwu = new Student(32, "王五");
        sx[1] = wangwu;

        // 查询数组的长度
        System.out.println(sx.length);

        // 遍历
        for(int i=0;i<sx.length;i++){
            System.out.println(sx[i]);
        }

        int i = 0;
        while(i  < sx.length){
            System.out.println(sx[i]);
        }



    }
}
